function f(a) {
	// console.log(a,'fff');
	if (a == 128)
		return [false, false, false, false, false, false, false, false];

	var z = [];
	for (var i = 0; i < 8; i++) {
		
		z.unshift((a & 1) == 0);
		a >>= 1;
	}
	// console.log(z,'zzzzzzzzzzz')
	return z;
}

function g(z) {
	var a = 0;
	for (var i = 0; i < 8; i++) {
		a <<= 1;
		if (!z[i]) a |= 1;
	}
	return Math.min(128, a);
}

function getAble(func) {
	
	function aes(s) {
		
		var s1 = '';
		for (var i = 0; i < s.length; i++)
			s1 = String.fromCharCode(s.charCodeAt(i) ^ 23) + s1;
		return s1;
	}
	/* var a = sessionStorage['hxt-a'];
	if (a) {
		func(Qs.parse(aes(a)));
		return;
	} */
	axios.get('/pc/user').then(function (res) {
		// console.log('resres',res)
		a = res.data.authority || {};
		sessionStorage['hxt-a'] = aes(Qs.stringify(a));
		func(a);
		setTimeout(function () {
			sessionStorage.removeItem('hxt-a');
		}, 60000);
	});
}

function abled(field, o) {
	//o是this实例
	getAble(function (a) {
		
		a = f(a[field] || 0);
		// console.log(a,'abled====');
		// ['查看','新增','修改','删除','导入','导出','进入校区','审批']
		o.able = {
			add: a[1],
			edit: a[2],
			// edit: false,
			del: a[3],
			import:a[4],
			export:a[5],
			enter:a[6],
			audit:a[7],
		};
	});
}